package ui.activity;

import com.stuassist.ui.R;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
import foundation.data.CourseData;
public class CourseAdapter<Object> extends ArrayAdapter<Object>
{
	private CourseData cData;     
    private LayoutInflater mInflater;
    public CourseAdapter(Context context, int resource, Object[] objects) 
    {
        super(context, resource, objects);
        // TODO Auto-generated constructor stub
        cData = new CourseData();
        mInflater = LayoutInflater.from(context);

    }
    
    @Override 
    public View getView(int position, View convertView, ViewGroup parent)
    {    
        //第一步，就是inflate我们自己的布局。想弄成什么样子的都行
        LinearLayout layout = new LinearLayout(getContext());
        mInflater.inflate(R.layout.array_item_view, layout, true);
        
        TextView text;            
        text = (TextView) layout.findViewById(R.id.textViewArrayItem);                         
        //根据position，取对应的数据。
        text.setText(cData.getDisplayname(position));
        //将额外的参数设置到View的TAG属性里，以提供在点击事件回调函数里面处理。
        layout.setTag(cData.getAction(position));
        return (View)layout;
    }
}